Skip to content

android: patch RN settings.gradle.kts /tmp projectDir for Windows - #387

Open
kraenhansen wants to merge 1 commit into
kh/adopt-static-h-node-apifrom
claude/windows-gradle9-projectdir
Open

android: patch RN settings.gradle.kts /tmp projectDir for Windows#387
kraenhansen wants to merge 1 commit into
kh/adopt-static-h-node-apifrom
claude/windows-gradle9-projectdir

Conversation

@kraenhansen

Copy link
Copy Markdown
Collaborator

Targets the kh/adopt-static-h-node-api branch (PR #372). Follow-up to #386, which greened ubuntu + macOS but left windows-latest red on a different cause.

Root cause

After #386 fixed the Project.exec() removal, the Windows Gradle build got further and both gradle.test.ts cases failed at configuration time:

Configuring project ':packages:react-native' without an existing directory is not allowed.
The configured projectDirectory '...\[email protected]...\node_modules\react-native\tmp' does not exist

This is upstream React Native, not our code. RN's own settings.gradle.kts (used for build-from-source composite builds, which this project requires) declares the intermediate container projects with a throwaway dir:

// Since Gradle 9.0, all the projects in the path must have an existing folder.
project(":packages").projectDir = file("/tmp")
project(":packages:react-native").projectDir = file("/tmp")

/tmp exists on the posix CI hosts, so ubuntu/macOS pass. On Windows /tmp is not absolute, so Gradle resolves it to a non-existent <react-native>\tmp, and Gradle 9 hard-errors on a missing projectDirectory — failing before any task runs.

Fix

There's no fixed RN release to bump to (pinned nightly), so this adds a pnpm patch replacing file("/tmp") with file(System.getProperty("java.io.tmpdir", "/tmp")) — the JVM temp dir, which is /tmp on posix and %TEMP% on Windows and always exists. The patch carries a comment with its removal condition (once RN stops hardcoding /tmp).

Files:

  • patches/[email protected]
  • pnpm-workspace.yaml (patchedDependencies entry)
  • pnpm-lock.yaml

Test plan

The native Android/Windows build isn't runnable on the Linux worker this was authored on, so the cross-platform behaviour is verified by CI on the #372 branch rather than locally. Worth reporting upstream to React Native so the /tmp hardcode is fixed at the source.


Generated by Claude Code

The Windows unit-test lane failed configuring the React Native build-from-
source composite build:

    Configuring project ':packages:react-native' without an existing directory
    is not allowed. The configured projectDirectory '...\react-native\tmp'
    does not exist

React Native's own settings.gradle.kts declares the intermediate container
projects :packages and :packages:react-native with projectDir = file("/tmp"),
purely to satisfy Gradle 9's rule that every project in a path have an existing
folder. "/tmp" exists on the posix CI hosts but on Windows it is not an
absolute path, so Gradle resolves it to a non-existent <react-native>\tmp and
the build fails before any task runs. This is why only windows-latest was red
while ubuntu and macOS passed.

Add a pnpm patch replacing file("/tmp") with
file(System.getProperty("java.io.tmpdir", "/tmp")): the JVM temp dir is "/tmp"
on posix and %TEMP% on Windows, both of which always exist. Remove the patch
once React Native stops hardcoding "/tmp" upstream.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TVfanKvtyfSsoMgZv3DJtY
meta-codesync Bot pushed a commit to react/react-native that referenced this pull request Jul 28, 2026
…ed /tmp (#57706)

Summary:
`packages/react-native/settings.gradle.kts` declares the intermediate container projects `:packages` and `:packages:react-native` with `projectDir = file("/tmp")`, to satisfy Gradle 9's requirement that every project in a path have an existing folder. `/tmp` exists on posix hosts, but on Windows it is not an absolute path, so Gradle resolves it to a non-existent `<rootDir>\tmp` and build-from-source fails at configuration time:

    Configuring project ':packages:react-native' without an existing directory
    is not allowed.

Use `System.getProperty("java.io.tmpdir", "/tmp")` instead — the JVM temp dir, which is `/tmp` on posix and `%TEMP%` on Windows, and always exists.

## Changelog

[ANDROID] [FIXED] - Use the JVM temp dir instead of a hardcoded `/tmp` for the build-from-source container project dirs, fixing Gradle configuration on Windows

Pull Request resolved: #57706

Test Plan:
- posix: the resolved dir is unchanged (`/tmp`); build-from-source configures as before.
- Windows: resolves to an existing temp dir, so `includeBuild(../node_modules/react-native)`
  configures successfully instead of erroring.
- Downstream evidence: this exact change greened the `windows-latest` Gradle lane in
  callstackincubator/react-native-node-api#387.

Reviewed By: christophpurrer

Differential Revision: D113816859

Pulled By: Abbondanzo

fbshipit-source-id: 9846dadab9012369dcab26aa05ea3297633acf9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants